/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package cn.ac.iie.di.gloabl;

import cn.ac.iie.di.tools.Configuration;
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.concurrent.ArrayBlockingQueue;
import org.apache.log4j.Logger;

/**
 *
 * @author lenovo-pc
 */
public class GlobalParas {

    static private final Logger logger = Logger.getLogger(GlobalParas.class.getName());
    public static ArrayBlockingQueue<String> msgQueue = new ArrayBlockingQueue(500);
    public static String IP_PORT = null;
    public static String FTP_IP = null;
    public static String MQ_MSG = null;
    public static String TYPE_MSG = null;
    public static String ORI_MSG = null;
    public static String DES_MSG = null;

    public static String FILE_MSG = null;
    public static String FILE_USER = null;
    public static int POOL_MSG = 20;

    public static HashSet<String> Center = new HashSet<>();
    private static final HashMap<String, String> propMap = new HashMap<>();
    private static final Configuration conf = Configuration.getConfiguration(ClassLoader.getSystemClassLoader().getResource("config.properties").getFile());

    static {
        //MQ端口号
        IP_PORT = LoadProperties("IP_PORT");

        FTP_IP = LoadProperties("FTP_IP");
        //消息队列名称
        MQ_MSG = LoadProperties("MQ_MSG");
        //解析字段
        TYPE_MSG = LoadProperties("TYPE_MSG");
        //需要解析的文件夹
        ORI_MSG = LoadProperties("ORI_MSG");

        //最后存放原始文件的文件夹
        DES_MSG = LoadProperties("DES_MSG");

        //不同的文件夹挪走文件处理不一致
        FILE_MSG = LoadProperties("FILE_MSG");
        FILE_USER = LoadProperties("FILE_USER");
        //设置线程池队列的大小
        POOL_MSG = Integer.parseInt(LoadProperties("POOL_MSG"));

    }

    public static String LoadProperties(String str) {
        if (propMap.containsKey(str)) {
        } else {
            synchronized (conf) {
                if (propMap.containsKey(str)) {
                } else {
                    propMap.put(str, conf.getString(str, ""));
                }
            }
        }
        return propMap.get(str);
    }

    public static void main(String[] args) {

    }

}
